home *** CD-ROM | disk | FTP | other *** search
- property numberOfChannels, baseStackSpr, moverStackSpr, holderStackSpr, STKorgH, STKorgV, STKminV, STKmaxV, STKiconHeight, STKiconGap, stackList, channelsInStack
- global currentFrame, dispatchTable, dirtyFlag
-
- on birth me
- init(me)
- return me
- end
-
- on init me
- set numberOfChannels to 12
- set baseStackSpr to 36
- set moverStackSpr to 48
- set holderStackSpr to 1
- set STKorgH to 20
- set STKorgV to 17
- set STKiconHeight to 30
- set STKiconGap to 1
- set STKminV to STKorgV + (STKiconHeight / 2)
- repeat with i = 36 to 48
- puppetSprite(i, 1)
- end repeat
- end
-
- on update me
- set channelsInStack to count(dispatchTable)
- set STKmaxV to STKorgV + (channelsInStack * (STKiconHeight + STKiconGap)) - (STKiconHeight / 2) - 1
- set stackList to []
- repeat with theLayerNum = 1 to channelsInStack
- set dispatchCell to getAt(dispatchTable, theLayerNum)
- set dispatchGroup to getAt(dispatchCell, 2)
- set iconCast to the number of cast ("icon." & dispatchGroup)
- if iconCast = -1 then
- set iconCast to the number of cast "icon.default"
- end if
- set iconSpr to theLayerNum + baseStackSpr - 1
- set curCell to [iconCast, iconSpr]
- add(stackList, curCell)
- end repeat
- set curPos to 0
- set curCount to 1
- repeat with theChannel = 36 to 47
- if curCount <= channelsInStack then
- set curCast to getAt(getAt(stackList, curCount), 1)
- set the castNum of sprite theChannel to curCast
- set the locH of sprite theChannel to STKorgH + (STKiconHeight / 2)
- set the locV of sprite theChannel to STKorgV + (STKiconHeight / 2) + (curPos * (STKiconHeight + STKiconGap))
- else
- set the locH of sprite theChannel to -1000
- end if
- set curPos to curPos + 1
- set curCount to curCount + 1
- end repeat
- end
-
- on shuffleStack me
- set whichSpr to the clickOn
- set offset to the locV of sprite whichSpr - STKorgV
- set sourceLayer to 1 + (offset / (STKiconHeight + STKiconGap))
- set sourceCast to the castNum of sprite whichSpr
- set the castNum of sprite moverStackSpr to sourceCast
- set the locH of sprite moverStackSpr to STKorgH + (STKiconHeight / 2)
- set the locH of sprite whichSpr to -1000
- set oldSpace to sourceLayer
- set curSpace to sourceLayer
- set stackChanged to 0
- set loopCheck to #outer
- repeat while the mouseDown
- set loopCheck to #outer
- if inside(point(the mouseH, the mouseV), rect(20, 20, 50, 389)) then
- set loopCheck to #inner
- set vMouse to the mouseV
- if vMouse < STKminV then
- set vMouse to STKminV
- end if
- if vMouse > STKmaxV then
- set vMouse to STKmaxV
- end if
- set the locV of sprite moverStackSpr to vMouse
- set offset to vMouse - STKorgV
- set newPos to 1 + (offset / (STKiconHeight + STKiconGap))
- updateStage()
- if newPos = curSpace then
- next repeat
- else
- set stackChanged to 1
- set dirtyFlag to 1
- end if
- set moveCell to getAt(stackList, curSpace)
- deleteAt(stackList, curSpace)
- addAt(stackList, newPos, moveCell)
- if newPos > curSpace then
- repeat with x = curSpace to newPos - 1
- put x
- puppetSound("stack snd")
- set curSpr to getAt(getAt(stackList, x), 2)
- set curV to the locV of sprite curSpr - 1
- repeat with y = 1 to 10
- set the locV of sprite curSpr to curV - (y * 3)
- updateStage()
- end repeat
- end repeat
- else
- repeat with x = curSpace down to newPos + 1
- put x
- puppetSound("stack snd")
- set curSpr to getAt(getAt(stackList, x), 2)
- set curV to the locV of sprite curSpr + 1
- repeat with y = 1 to 10
- set the locV of sprite curSpr to curV + (y * 3)
- updateStage()
- end repeat
- updateStage()
- end repeat
- end if
- end if
- if loopCheck = #inner then
- set oldSpace to curSpace
- set curSpace to newPos
- end if
- end repeat
- set the locH of sprite moverStackSpr to -1000
- set the locH of sprite whichSpr to STKorgH + (STKiconHeight / 2)
- set the locV of sprite whichSpr to STKorgV + (STKiconHeight / 2) + ((curSpace - 1) * (STKiconHeight + STKiconGap))
- if sourceLayer <> curSpace then
- set moveCell to getAt(dispatchTable, sourceLayer)
- deleteAt(dispatchTable, sourceLayer)
- addAt(dispatchTable, curSpace, moveCell)
- end if
- showFrame(playbackMgr, currentFrame, 0)
- if not stackChanged then
- doSelectClip(me)
- end if
- startTimer()
- end
-
- on doSelectClip me
- set whichSpr to the clickOn
- set cNum to the castNum of sprite whichSpr
- set the itemDelimiter to "."
- set castRoot to item 2 of the name of cast cNum
- set the itemDelimiter to ","
- set cnt to 0
- set scoreChannel to 0
- repeat with curRec in dispatchTable
- set cnt to cnt + 1
- if castRoot = getAt(curRec, 2) then
- set scoreChannel to cnt + 2
- exit repeat
- end if
- end repeat
- if scoreChannel <> 0 then
- set onStage to 0
- set cNum to 0
- if the locH of sprite scoreChannel > 0 then
- set cNum to the castNum of sprite scoreChannel
- set onStage to 1
- end if
- if onStage then
- selectClip(editMgr, scoreChannel)
- end if
- end if
- end
-